import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/js/bootstrap.bundle.min.js'
import 'bootstrap-icons/font/bootstrap-icons.css'
import ToastNotification from './components/Toast.vue'

const pinia = createPinia()
const app = createApp(App)

// 创建Toast全局组件
app.component('ToastNotification', ToastNotification)

// 在window上挂载Toast方法，方便调用
window.showToast = (message, options) => {
  // 查找Toast组件实例
  const toastInstance = document.querySelector('#toast-container')?.
    __vueParentComponent?.ctx
  
  if (toastInstance) {
    toastInstance.show(message, options)
  } else {
    console.warn('Toast component not found')
  }
}

app.use(router)
app.use(pinia)
app.mount('#app') 